# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libevent' 'libevent-devel')
pkgver=2.1.4
pkgrel=1
pkgdesc="An event notification library"
arch=('i686' 'x86_64')
url="http://www.monkey.org/~provos/libevent/"
license=('BSD')
makedepends=('openssl-devel')
source=(${pkgname}-${pkgver}-alpha.tar.gz::"https://github.com/${pkgname}/${pkgname}/archive/release-${pkgver}-alpha.tar.gz")
md5sums=('3db1e1169357a34c0ab5b2aced06e5b1')

prepare() {
  cd ${srcdir}/${pkgname}-release-${pkgver}-alpha
  ./autogen.sh
}

build() {
  cd ${srcdir}/${pkgname}-release-${pkgver}-alpha
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc
  make
  make DESTDIR="$srcdir/dest" install
}

package_libevent() {
  depends=('openssl')
  optdepends=('python2: to use event_rpcgen.py')

  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin $pkgdir/usr/
  install -Dm644 $srcdir/${pkgname}-release-${pkgver}-alpha/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_libevent-devel() {
  pkgdesc="Libevent headers and libraries"
  groups=('development')
  depends=("libevent=${pkgver}" "openssl-devel")

  mkdir -p $pkgdir/usr
  cp -rf $srcdir/dest/usr/include $pkgdir/usr/
  cp -rf $srcdir/dest/usr/lib $pkgdir/usr/
}
